Skip to content

Copy custom attributes onto generated stunts - #244

Merged
kzu merged 1 commit into
mainfrom
dev/signature-ref-generator
Sep 30, 2026
Merged

kzu merged 1 commit into
mainfrom
dev/signature-ref-generator

Conversation

@kzu

@kzu kzu commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

scaffold the stunt
  copy attributes reflection will not see on the override
    type and method: non-inherited only ([Serializable], [Guid])
    property, event, parameter, return, constructor: all of them
  optional defaults become [Optional] and [DefaultParameterValue]
    an override cannot spell = value (CS1066)
rewrite accessors
  keep those attributes on get, set, add, and remove

Evidence

  • Before: A generated stunt did not carry [Serializable], [Guid], or parameter attributes. Reflection on the stunt method did not report an optional default, and Invoke with Type.Missing could not supply it.
    After: AttributeTests calls Defaulted(), Price(), and OptionalName() with the argument omitted and sees 5, 1.5m, and "none" in the behavior and the return value. Reflection Invoke with Type.Missing uses the copied default, including Echo(Type.Missing, "other").
dotnet test --filter "FullyQualifiedName~Scenarios|FullyQualifiedName~StuntGeneratorTests|FullyQualifiedName~StuntScaffoldTests"
Passed!  - Failed: 0, Passed: 40

Merge Danger

Door: two-way

Reverting the generator restores the previous stunt shape.

Blast Radius: generated types

[Serializable] and [Guid] on the stunt change reflection, COM identity, and formatter-based serialization for proxies of types that already had those attributes. Inheritable type and method attributes are not copied again.

@kzu kzu added the enhancement New feature or request label Sep 30, 2026
@kzu
kzu force-pushed the dev/signature-ref-generator branch from af0f1d7 to c9db1e8 Compare September 30, 2026 01:23
@kzu kzu changed the title Report unsafe stunt signatures and copy custom attributes onto the generated type Copy custom attributes onto generated stunts Sep 30, 2026
…d calls see them.

Optional defaults are emitted as attributes, since an override cannot spell = value without a warning.
@kzu
kzu force-pushed the dev/signature-ref-generator branch from c9db1e8 to 5aa4370 Compare September 30, 2026 01:25
@kzu
kzu enabled auto-merge (rebase) September 30, 2026 01:25
@kzu
kzu merged commit 3350f07 into main Sep 30, 2026
6 checks passed
@kzu
kzu deleted the dev/signature-ref-generator branch September 30, 2026 01:29
@devlooped devlooped locked and limited conversation to collaborators Nov 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant